package com.aierkeji.call.b2c.service;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aierkeji.call.b2c.dao.jpa.AkjCallVersionDao;
import com.aierkeji.call.b2c.entity.AkjCallVersion;
import com.aierkeji.call.b2c.util.AppConfig;

@Service
public class AkjCallVersionService {

	@Autowired
	private AkjCallVersionDao akjCallVersionDao;

	public LocalDateTime updateDateTime ;
	
	private AkjCallVersion akjCallVersion = null;
	
	public AkjCallVersion getVersion() {
//		if(updateDateTime==null) {
		AkjCallVersion akjCallVersion = this.akjCallVersionDao.findFirstByOrderByIdDesc();
//			 updateDateTime = LocalDateTime.now();
//		}
//		else if(updateDateTime.isBefore(LocalDateTime.now().minusMinutes(Integer.parseInt(AppConfig.getProperty("checkVersionDateTime","30"))))) {
//			akjCallVersion = this.akjCallVersionDao.findFirstByOrderByIdDesc();
//			 updateDateTime = LocalDateTime.now();
//		}
		return akjCallVersion;
	}
	
	public static void main(String[] args) {
		LocalDateTime l1 = LocalDateTime.now().minusMinutes(10);
		System.out.println(l1);
	}
		
}
